﻿<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>jQueryHTML之attr()</title>
        <script src="js/jquery-3.6.1.min.js"></script>
    </head>
    <body>
        <h3>jQueryHTML之attr()</h3>
        <hr>
		<img src="image/gongfu.jpg" width="300" height="450">
		<br>
		<button id="btn01">点击此处获取海报图片URL</button>
		<button id="btn02">点击此处切换海报图片URL</button>
        <script>
            $(document).ready(function() {
				//按钮1的点击事件：获取HTML内容
                $("#btn01").click(function() {
                    var src = $("img").attr("src");
                    alert("当前图片的src属性值为：" + src);
                });
				//按钮2的点击事件：重置HTML内容
                $("#btn02").click(function() {
                    $("img").attr("src","image/duola.jpg");
                });
            });
        </script>
	</body>
</html>